<?php
    function check_attendance($arr, $date, $class_shift){
        foreach($arr as $one){
            if($date == $one['date'] && $class_shift == $one['class_shift']) return true;
        }
        return false;
    }
?>
<br/>
<center><?php echo $program_name ?></center>
<br/>
<?php if(count($teachers) > 0) { ?>
<?php  

?>
<form action="<?php echo url_for('program/attendanceFill') ?>" method="post"> 
    <input type="hidden" name=id value="<?php echo $program_id ?>" />
    <div class="teacher_names_wrap">
        <table border="0">
            <tr>
                <th>
                    <?php echo __('Teacher Name') ?>
                </th>
            </tr>
            <?php foreach($teachers as $one) { ?>
            <tr>
                <td>
                    <?php $teacher = $one['Teacher'] ?>
                    <?php echo $teacher['f_name'].' '.$teacher['s_name'].' '.$teacher['t_name'].' '.$teacher['l_name'] ?>
                </td>
            </tr>
            <?php } ?>
        </table>
    </div>
    <div class="attendance_wrap">
        <table width="100%" border="0" dir="rtl">
            <tr>
                <?php foreach($days as $k => $one) { ?>
                    <th dir="ltr">
                        <?php echo $one ?>
                    </th>
                <?php } ?>
            </tr>
            <?php foreach($teachers as $one) { ?>
            <tr>
             
                <?php $teacher = $one['Teacher'] ?>
                <?php for($i = 0 ; $i <= $k ; $i++){ ?>
                    <td align="center" class="shift">
                       <table align="center" border="0" width="100%" cellpadding="0" cellspacing="0">
                           <tr>
                               <td width="20%"><label for="morning<?php echo $days[$i] ?><?php echo $teacher['intg_identity'] ?>">1</label></td>
                               <td><input id="morning<?php echo $days[$i] ?><?php echo $teacher['intg_identity'] ?>" <?php if(check_attendance($teacher['Attendance'], $days[$i], 'morning')) echo 'checked="checked"' ?> name="attendance[<?php echo $days[$i] ?>x<?php echo $teacher['intg_identity'] ?>xmorning]" type="checkbox"/></td>
                               <td width="20%"><label for="afternoon<?php echo $days[$i] ?><?php echo $teacher['intg_identity'] ?>">2</label></td>
                               <td><input id="afternoon<?php echo $days[$i] ?><?php echo $teacher['intg_identity'] ?>" <?php if(check_attendance($teacher['Attendance'], $days[$i], 'afternoon')) echo 'checked="checked"' ?> name="attendance[<?php echo $days[$i] ?>x<?php echo $teacher['intg_identity'] ?>xafternoon]" type="checkbox"/></td>
                           </tr>
                       </table>
                    </td>
                <?php } ?>
            </tr>
            <?php } ?>
        </table>
    </div>
    <div class="clear"></div>
    <br/>
    <br/>
    <center><button class="kts_button"><?php echo __('Save') ?></button></center>
</form>
<?php } else { ?>
<center><?php echo __('there_are_no_teachers') ?></center>
<?php } ?>


